package org.dromara.business.modules.message.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.business.modules.message.domain.bo.BuMessageBo;
import org.dromara.business.modules.message.domain.vo.BuMessageVo;
import org.dromara.business.modules.message.service.IBuMessageService;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 消息通知
 *
 * @author ckk
 * @date 2025-10-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/message")
public class BuMessageController extends BaseController {

    private final IBuMessageService buMessageService;

    /**
     * 查询消息通知列表
     */
    @GetMapping("/list")
    public TableDataInfo<BuMessageVo> list(BuMessageBo bo, PageQuery pageQuery) {
        return buMessageService.queryPageList(bo, pageQuery);
    }

    /**
     * 设置已读
     */
    @PostMapping("/setRead")
    public R<Boolean> setRead(@RequestParam(defaultValue = "-1") Long id) {
        return R.ok(buMessageService.setRead(id));
    }

    /**
     * 未读数量
     */
    @GetMapping("/unReadCount")
    public R<Long> unReadCount() {
        return R.ok(buMessageService.unReadCount());
    }
}
